﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BattleOfColors.Model
{
    public class Direction : IComparable
    {
        private Movement _movement;

        public Movement Movement
        {
            get { return _movement; }
            set { _movement = value; }
        }

        private float _weight;

        public float Weight
        {
            get { return _weight; }
            set { _weight = value; }
        }

        public Direction(Movement Movement, float Weight)
        {
            this.Movement = Movement;
            this.Weight = Weight;
        }

        /// <summary>
        /// Método para a comparação de duas direções pelo peso
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return 1;
            }

            if (obj is Direction)
            {
                Direction anotherDirection = (Direction)obj;

                if (anotherDirection.Weight > Weight)
                {
                    return 1;
                }
                else
                {
                    return -1;
                } 
            }
            else
            {
                return 1;
            }
        }
    }
}
